﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>自动触发子流程</title>
    <link href="../../../Comm/Style/CommStyle.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" />
    <script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <base target="_self" />
    <script src="../../Admin.js"></script>
    <style>
        #Btn_New2 {
            border: 1px solid #031f5d;
            background-color: #fff;
            color: #031f5d;
            background-image: url(../../../Img/Btn/New.png);
            background-repeat: no-repeat;
            background-size: 13px 13px;
            background-position: 1px 6px;
        }
    </style>
    <script type="text/javascript">
        //打开窗体.
        function OpenEasyUiDialogExt(url, title, w, h, isReload) {

            OpenEasyUiDialog(url, "eudlgframe", title, w, h, "icon-property", true, null, null, null, function () {
                if (isReload == true) {
                    window.location.href = window.location.href;
                }
            });
        }

        //页面启动函数.
        $(function () {

            $("#Msg").html("<img src=../../../Img/loading.gif />&nbsp;正在加载,请稍后......");

            //求出来已经设置的自动触发子流程.
            var nodeID = GetQueryString("FK_Node");
            var ens = new Entities("BP.WF.Template.SubFlowAutos");
            ens.Retrieve("FK_Node", nodeID, "SubFlowType", 1, "Idx");

            var node = new Entity("BP.WF.Node", nodeID);
            node.SetPara("SubFlowAutoNum", ens.length);
            node.Update();

            //console.log(ens);

            var html = "";
            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];
                html += "<tr>";
                html += "<td class=Idx>" + (i + 1) + "</td>";
                html += "<td>" + en.SubFlowNo + "</td>";
                html += "<td>" + en.SubFlowName + "</td>";
                html += "<td>" + en.SubFlowModelText + "</td>";
                html += "<td>" + en.SendModelText + "</td>";

                //  html += "<td>" + en.YGWorkWayText + "</td>";
                html += "<td><a href=\"javascript:Edit('" + en.MyPK + "');\" >编辑</a></td>";
                html += "<td><a href=\"javascript:SetCond('" + en.MyPK + "');\" >设置条件</a></td>";
                html += "<td>";
                html += "<a href=\"javascript:DoUp('" + en.MyPK + "')\">上移</a> - <a href=\"javascript:DoDown('" + en.MyPK + "')\">下移</a>";
                html += "</td>";
                html += "</tr>";
            }

            $("#Table1 tr:last").after(html);

            $("#Msg").html("");

        });

        function DoUp(mypk) {
            var en = new Entity("BP.WF.Template.SubFlowAuto", mypk);
            en.DoMethodReturnString("DoUp");
            window.location.href = window.location.href;
        }
        function DoDown(mypk) {
            var en = new Entity("BP.WF.Template.SubFlowAuto", mypk);
            en.DoMethodReturnString("DoDown");
            window.location.href = window.location.href;
        }

        //查询集团的流程.
        function AddGroup() {
            var webUser = new WebUser();

            var url = "SubFlowAutoDtl.htm?FK_Node=" + GetQueryString("FK_Node") + "&OrgNo=" + webUser.GroupNo;
            OpenEasyUiDialogExt(url, "选择子流程", 500, 400, true);
        }
        //查询集团的流程.
        function AddOrg() {
            var webUser = new WebUser();
            var url = "SubFlowAutoDtl.htm?FK_Node=" + GetQueryString("FK_Node") + "&OrgNo=" + webUser.FK_Dept;
            OpenEasyUiDialogExt(url, "选择子流程", 500, 400, true);
        }

        //删除成功.
        function Delete(pk) {

            if (confirm('您确定要删除吗？') == false)
                return;

            var en = new Entity("BP.WF.Template.SubFlowAuto", pk);
            en.Delete();
            window.location.href = window.location.href;
        }

        //设置子流程启动条件.
        function SetCond(pk) {
            var en = new Entity("BP.WF.Template.SubFlowAuto", pk);
            var url = "../../Cond2020/List.htm?CondType=3&FK_Flow=" + en.FK_Flow + "&FK_MainNode="+ en.FK_Node +"&FK_Node=" + en.FK_Node + "&ToNodeID=" + en.FK_Node + "&SubFlowNo=" + en.SubFlowNo;
            window.location.href = url;
            return;


            //var url = "../../../Comm/RefFunc/EnOnly.htm?EnName=BP.WF.Template.SubFlowAuto&PKVal=" + pk;

            //OpenEasyUiDialogExt(url, '', 700, 500, true);

            //OpenEasyUiDialogExt(url, '编辑', 500, 400, true);
            //window.location.href = url;
        }



        //编辑.
        function Edit(pk) {

            var url = "../../../Comm/RefFunc/EnOnly.htm?EnName=BP.WF.Template.SubFlowAuto&PKVal=" + pk;

            OpenEasyUiDialogExt(url, '编辑', 700, 500, true);
            //OpenEasyUiDialogExt(url, '编辑', 500, 400, true);

            //window.location.href = url;

        }
        function Help() {
            var url = "http://ccbpm.mydoc.io";
            window.open(url);
        }
    </script>
</head>
<body>
    <div style="right:30px; position:absolute; z-index:100; top:-4px">
        <input id="Btn_New" type="button" value="增加集团子流程" onclick="AddGroup()" />
        <input id="Btn_New2" type="button" value="增加本组织子流程" onclick="AddOrg()" />
        <input id="Btn_Help" type="button" value="帮助" onclick="Help()" />
    </div>
    <table id="Table1" style="width: 100%">
        <caption>
            <img style="margin-bottom:8px;" align="middle" src='../../../Img/Event.png' />
            自动触发子流程
        </caption>
        <tr>
            <th>
                序
            </th>
            <th>
                编号
            </th>
            <th>
                流程名称
            </th>
            <th>
                运行模式
            </th>
            <th>
                发送模式
            </th>
            <th>
                编辑
            </th>
            <th>
                删除
            </th>
            <th>
                顺序
            </th>
        </tr>
    </table>
    <br />

    <div style="position:relative;" id="Msg">
    </div>
    <!--
    <fieldset>
                    <legend>填写帮助</legend>
                    <ul>
                        <li>延续流程就是当前的子流程.</li>
                        <li>延续流程是子流程的一种,该子流程只能被发起一次.</li>
                    </ul>
                </fieldset>-->
</body>
</html>
